package main;

import common.entities.persistent.Movie;

import kernel_db.db.DB;
import kernel_db.interfaces.IDB;
import kernel_gui.gui.GUIControl;
import kernel_gui.interfaces.IGUI;


public class mainFunction {

	public static void main(String[] args) {
		iniParams params = iniParams.readINIFile(args);
		
		Movie.setReleaseYearMaxValue(params.getMaxMovieYear());
		IDB db = new DB(params.getServerPath(), params.getUserName(), params.getPassword(), 
						params.getMaxMovieYear(), params.getMaxBatch(), params.getFetchSize());
		db.setDBFilesPaths(params.getMoviesFilePath(), params.getRatingsFilePath(), params.getCountriesFilePath(),
							params.getGenresFilePath(), params.getActorsFilePath(), params.getActressesFilePath(),
							params.getDirectorsFilePath());
		
		Kernel k = new Kernel(db, params.getMaxMovieYear());
	
		
		try{
			GUIControl.initGUIControl(k);
			IGUI Gui = GUIControl.getGUIControlInstance();
			k.setGui(Gui);
			GUIControl.startGUI();
		}catch(Exception e){
			k.exitMillioner(0);
			System.out.println("We have an exception");
		}
		
	
	}

}
